package com.tubi.Exception;

import java.text.ParseException;

public class tryCatch {
    public static void main(String[] args) throws ParseException {
        //好处：为了能让代码继续执行
        int[] arr = null;
        try{ //有可能出现嗯嗯异常代码
            method1(arr);
        }catch (NullPointerException e){
            //如果出现这样的异常怎么解决
            System.out.println("参数不能为null");
        }
    }

    private static void method1(int[] arr) {
        if (arr == null) {
            throw new NullPointerException();
        }else {
            for (int i = 0; i < arr.length; i++) {
                System.out.println(arr[i]);
            }
        }

    }
}
